<!--部门利润分红明细数据-->
<template>
  <div>
    <f-search-form ref='search' :more='true' @searchHandler='searchHandler'>
      <f-search-form-item label='部门' name='deptId' type='select' :data='api.dept.list' :params='{auth:1}' value-key='deptId' label-key='deptName' @change='deptChange' />
      <f-search-form-item label='业务员' name='customName' />
      <f-search-form-item label='回款日期' type='date' name='endDate' />
      <f-search-form-item label='订单编号' name='orderNo' slot='advanced' />
      <f-search-form-item label='发货方式' name='supplierRefundState' type='select' :data='api.busCommon.refundState' slot='advanced'></f-search-form-item>
      <f-search-form-item label='发货日期' type='date' name='beginDate' slot='advanced' />
    </f-search-form>
    <f-table ref='table' rowKey='orderDetailsId' :showSetting='true' :multiple='false' setting-key='bonus_tab1' :tableColumns='columns' :scroll='{x:true}' handler='noSettlePageListHandler' :showMultipleBtn='false' :operator='operator' :params='queryParam' :dataSource='dataSource' :api='api.bod'>
       <span slot='ownerState' slot-scope='text, record, index'>
            <a-tag color='#108ee9' v-if='text==0'>否</a-tag>
            <a-tag color='#f50' v-if='text==1'>是</a-tag>
       </span>
      <span slot='supplierBondType' slot-scope='text, record, index'>
            <a-tag color='#2db7f5' v-if='text==0'>不垫付</a-tag>
            <a-tag color='purple' v-if='text==1'>底价</a-tag>
            <a-tag color='purple' v-if='text==2'>底价+税金</a-tag>
            <a-tag color='purple' v-if='text==3'>税金</a-tag>
            <a-tag color='purple' v-if='text==6'>底价/2+税金</a-tag>
            <a-tag color='purple' v-if='text==5'>全额垫付</a-tag>
            <a-tag color='purple' v-if='text==8'>销售金额*费率</a-tag>
        </span>
      <span slot='customBondType' slot-scope='text, record, index'>
           <a-tag color='#2db7f5' v-if='text==0'>全款</a-tag>
            <a-tag color='purple' v-if='text==1'>底价</a-tag>
            <a-tag color='purple' v-if='text==2'>底价+税金</a-tag>
            <a-tag color='purple' v-if='text==6'>底价/2+税金</a-tag>
            <a-tag color='purple' v-if='text==3'>税金</a-tag>
            <a-tag color='purple' v-if='text==5'>全额资信</a-tag>
            <a-tag color='purple' v-if='text==7'>预付款</a-tag>
        </span>
      <span slot='action' slot-scope='text, record'>
          <template>
            <a href='javascript:;' @click='settleSub(record)'>结算</a>
            <a-divider type='vertical' />
            <a @click='$refs.orderInfoDrawer.showDrawer(record)'>查看</a>
          </template>
        </span>
    </f-table>

  </div>
</template>
<script>
import api from "../../js/api"

export default {
  name: "Tab1",
  components: {},
  data() {
    let me = this
    //操作按钮
    let operator = []
    return {
      api: Object.assign(api, this.api),
      multiple: false,
      deptId: "",
      //列表初始化查询参数
      queryParam: {
        auth: 1
      },
      returnCustomBond: 0,
      selectIds: "",
      params1: {
        deptId: ""
      },
      dataSource: [{
        paymentId: 1,
        deptName: "商务一部",
        orderNo: "202305047894",
        saleManName: "王硕",
        drugsType: "自营",
        drugsName: "樟脑软膏",
        sendType: "现款",
        drugsSpec: "20g：2g",
        capacityNum: "400",
        drugsLotNo: "20547896",
        amount: "857847",
        salePrice: "2.56",
        costPrice: "1.56",
        settlePrice: "1.56",
        deptSettlePrice: "1.56",
        settleTaxRate: 0.13,
        companyName: "丹博瑞",
        areaName: "山西",
        saleNum: 2000,
        saleAmount: 5000,
        costAmount: 2000,
        returnAmount: 5000,
        feePaidAmount: 3000,
        returnDate: "2023-05-01",
        saleManNo: "Y1A渝A001",
        userName: "测试",
        paymentState: 0,
        deptSettleTaxRate: 0.185,
        taxTateDiff: 185,
        pieceNum: 1,
        deptProfit: 1258,
        bonusState: 0,
        orderDate: "2023-05-06"
      }],
      columns: [
        {
          title: "序号",
          width: "60px",
          align: "left",
          fixed: "left",
          customRender: (text, record, index) => index + 1
        },
        {
          title: "单据日期",
          align: "left",
          width: "100px",
          fixed: "left",
          dataIndex: "orderDate"
        },
        {
          title: "订单编号",
          align: "left",
          width: "130px",
          fixed: "left",
          dataIndex: "orderNo"
        },
        {
          title: "单位名称",
          align: "left",
          width: "100px",
          dataIndex: "companyName"
        },
        {
          title: "部门名称",
          align: "left",
          width: "100px",
          dataIndex: "deptName"
        },
        {
          title: "业务片区",
          align: "left",
          ellipsis: true,
          width: "110px",
          dataIndex: "areaName"
        },
        {
          title: "结算区域",
          align: "left",
          width: "100px",
          dataIndex: "saleManNo"
        },
        {
          title: "业务员",
          align: "center",
          ellipsis: true,
          width: "100px",
          dataIndex: "saleManName"
        },
        {
          title: "商品类型",
          align: "left",
          ellipsis: true,
          width: "80px",
          dataIndex: "drugsType"
        },
        {
          title: "发货方式",
          align: "left",
          ellipsis: true,
          width: "100px",
          dataIndex: "sendType"
        },
        {
          title: "商品名称",
          align: "left",
          ellipsis: true,
          width: "140px",
          dataIndex: "drugsName"
        },
        {
          title: "规格",
          align: "left",
          width: "80px",
          dataIndex: "drugsSpec"
        },
        {
          title: "件容",
          align: "left",
          width: "80px",
          dataIndex: "capacityNum"
        },
        {
          title: "批号",
          align: "left",
          width: "80px",
          dataIndex: "drugsLotNo"
        },
        {
          title: "销售单价",
          align: "left",
          width: "80px",
          dataIndex: "salePrice"
        },
        {
          title: "数量",
          align: "left",
          width: "80px",
          dataIndex: "saleNum"
        },
        {
          title: "销售金额",
          align: "left",
          width: "80px",
          dataIndex: "saleAmount"
        },
        {
          title: "回款金额",
          align: "left",
          width: "100px",
          dataIndex: "returnAmount"
        }, {
          title: "回款日期",
          align: "left",
          width: "100px",
          dataIndex: "returnDate"
        }, {
          title: "件数",
          align: "left",
          width: "100px",
          dataIndex: "pieceNum"
        },
        {
          title: "成本价",
          align: "left",
          width: "80px",
          dataIndex: "costPrice"
        },
        {
          title: "成本金额",
          align: "left",
          width: "120px",
          dataIndex: "costAmount"
        },
        {
          title: "统一结算价",
          align: "left",
          width: "90px",
          dataIndex: "settlePrice"
        },
        {
          title: "返利政策",
          align: "left",
          width: "90px",
          dataIndex: "policyRebate"
        },
        {
          title: "市场结算税率",
          align: "left",
          width: "90px",
          dataIndex: "settleTaxRate"
        },
        {
          title: "已付费用",
          align: "left",
          width: "90px",
          dataIndex: "feePaidAmount"
        },
        {
          title: "部门结算价",
          align: "left",
          width: "90px",
          dataIndex: "deptSettlePrice"
        },
        {
          title: "部门结算税率",
          align: "left",
          width: "90px",
          dataIndex: "deptSettleTaxRate"
        }, {
          title: "税率差",
          align: "left",
          width: "90px",
          dataIndex: "taxTateDiff"
        },
        {
          title: "部门利润",
          align: "left",
          width: "90px",
          fixed: "right",
          dataIndex: "deptProfit"
        }
      ],
      operator: operator
    }
  },
  created() {
  },
  computed: {
    rowSelection() {
      return {
        getCheckboxProps: record => ({
          props: {
            disabled: record.bonusState != 0, // Column configuration not to be checked
            name: record.bonusState
          }
        })
      }
    }

  },
  methods: {
    setData() {
    },
    settleSub(record) {

    },

    //部门切换
    deptChange(value) {
      this.queryParam.deptId = value
      if (this.queryParam.deptId) {
        this.multiple = true
        this.$refs.table.openMultiple()
      } else {
        this.multiple = false
        this.$refs.table.closeMultiple()
      }
      this.$refs.table.refresh(false)
    },
    /**
     * 查询事件
     * @param searchParams
     */
    searchTable(searchParams) {
      this.queryParam = Object.assign(this.queryParam, searchParams)
      this.$refs.table.refresh(true, searchParams)
    },
    openMultiple(searchParams) {
      if (searchParams.deptId) {
        this.multiple = true
        this.deptId = searchParams.deptId
      }
    },
    /**
     * 刷新列表
     */
    onLoad() {
      this.$refs.table.refresh()
      this.$emit("changeTab")
    }
  }
}
</script>